package com.ruoyi.web.controller.hospital;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.hospital.ActPatList;
import com.ruoyi.common.core.domain.hospital.PostResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.hospital.service.IActPatListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/hospital/ActPatList")
public class ActPatListController extends BaseController {

    @Autowired
    IActPatListService actPatListService;

//    @PreAuthorize("@ss.hasPermi('hospital:ActPatList:list')")
    @GetMapping("/list")
    public TableDataInfo list(ActPatList actPatList) {
//        actPatList.setPageNum((actPatList.getPageNum() - 1) * actPatList.getPageSize());
//        System.out.println(actPatList.getPageNum());
//        System.out.println(actPatList.getPageSize());
        List<ActPatList> list = actPatListService.getActPatList(actPatList);
        Integer total = actPatListService.getActPatListCount(actPatList);
        return getDataTable(list,total);
    }
    @GetMapping("/add")
    public AjaxResult add(ActPatList actPatList) {
        String id = actPatList.getPatientId() + "-" + actPatList.getInNums();
        System.out.println(id);
        actPatList.setId(id);
        actPatListService.addActPatList(actPatList);
        return success(actPatList);
    }
    @GetMapping("/update")
    public AjaxResult update(ActPatList actPatList) {
        String id = actPatList.getPatientId() + "-" + actPatList.getInNums();
        System.out.println(id);
        actPatList.setId(id);
        actPatListService.updateActPatList(actPatList);
        return success("更新成功");
    }

    @GetMapping("/getPostLog")
    public TableDataInfo getPostLog(PostResult postResult) {
        startPage();
        List<PostResult> postResultList = actPatListService.selectPostResultList(postResult);
        return getDataTable(postResultList);
    }
}
